package com.itheima.health.controller;

import com.itheima.health.resource.entity.Result;
import com.itheima.health.resource.pub.MessageConstant;
import com.itheima.health.service.MenuService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("menu")
public class MenuController {


    @Reference
    MenuService menuService;

    //查询菜单
    @RequestMapping("findMenuByUsername.do")
    public Result findMenuByUsername(@RequestParam("username") String username) {
        try {
            List<Map> list = menuService.findMenuByUsername(username);
            return new Result(true,MessageConstant.GET_MENU_SUCCESS,list);
        } catch (Exception e) {
            return new Result(false, MessageConstant.GET_MENU_FAIL);
        }
    }
}
